package com.dt76.smallloanbackenduser.controller.afterloan;



import com.dt76.smallloanbackenduser.pojo.afterloan.InspectionCommitInfo;
import com.dt76.smallloanbackenduser.pojo.afterloan.InspectionSimpleLoanMessage;
import com.dt76.smallloanbackenduser.pojo.afterloan.RepaymentQualification;
import com.dt76.smallloanbackenduser.remote.afterloan.InspectionRemote;
import com.dt76.smallloanbackenduser.utils.PageResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Controller
public class InspectionController {

    private final InspectionRemote inspectionRemote;

    public InspectionController(InspectionRemote inspectionRemote) {
        this.inspectionRemote = inspectionRemote;
    }

    @GetMapping("/inspectionManager")
    public String jumpToInspection() {
        return "/pages/afterloan/inspectionManager";
    }

    @ResponseBody
    @PostMapping("/inspection/list/{page}/{size}")
    public PageResult getPageList(@RequestBody RepaymentQualification q, @PathVariable Integer page, @PathVariable Integer size) {
        return inspectionRemote.getPageList(q, page, size);
    }

    @ResponseBody
    @PostMapping("/inspection/commitNormal")
    public Integer simpleLoanInfoSearch(@RequestBody InspectionCommitInfo commitInfo) {
        System.out.println(commitInfo);
        return inspectionRemote.simpleLoanInfoSearch(commitInfo);
    }

    @ResponseBody
    @RequestMapping("/inspection/getAllSimpleLoanMessage")
    public List<InspectionSimpleLoanMessage> getAllSimpleLoanMessage(){
        return inspectionRemote.getAllSimpleLoanMessage();
    }

    @ResponseBody
    @RequestMapping("/inspection/getTheSimpleLoanMessage")
    public List<InspectionSimpleLoanMessage> getTheSimpleLoanMessage(@RequestBody InspectionCommitInfo info){
        return inspectionRemote.getTheSimpleLoanMessage(info);
    }

}
